package com.njegovanobradovic.components;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.njegovanobradovic.entities.Message;
import com.njegovanobradovic.so.Save;


public class ContactForm {
	@Inject
	private Save<Message> saveMessage;
	@Property
	private String name;
	@Property
	private String eMail;
	@Property
	private String text;
	
	@CommitAfter
    public void onSuccess(){
    	try {
    		Message message = new Message();
    		message.setName(name);
    		message.seteMail(eMail);
    		message.setMessage(text);
    		saveMessage.setObject(message);
    		saveMessage.execute();
		} catch (Exception e) {
		}
    }
}
